package br.com.lambdacore.lang.reflect;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;

import net.vidageek.mirror.dsl.Mirror;
import br.com.lambdacore.lang.reflect.mirror.matcher.AccessibleObjectMatcher;

public abstract class AnnotationUtils {

	public static <T> Collection<Constructor<T>> getAllConstructorAnnoted(
			Class<T> clazz, Class<? extends Annotation>... annotation) {
		return new Mirror().on(clazz).reflectAll().constructorsMatching(
				AccessibleObjectMatcher
						.<T> isConstructorAnnotationPresent(annotation));
	}

	public static Collection<Field> getAllFieldsAnnoted(Class<?> clazz,
			Class<? extends Annotation>... annotation) {
		return new Mirror().on(clazz).reflectAll().fieldsMatching(
				AccessibleObjectMatcher.isFieldAnnotationPresent(annotation));
	}

	public static Collection<Method> getAllMethodsAnnoted(Class<?> clazz,
			Class<? extends Annotation>... annotation) {
		return new Mirror().on(clazz).reflectAll().methodsMatching(
				AccessibleObjectMatcher.isMethodAnnotationPresent(annotation));
	}

}
